package com.lyw.GeoLocationClient.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class GeotableDBHelper extends SQLiteOpenHelper{
	public static final String GEOTABLE_DBNAME = "geotable.db";
    public static final String GEO_TABLE = "geo_table";
    public static final String GEO_ID = "geo_id";
    public static final String GEO_TITLE = "title";//用户名
    public static final String POL_ID = "pol_id";
    public static final String PUSH_ID = "push_id";
    public static final String PUSH_CHANNEL = "push_channel";
    public static final String NAME = "name";//姓名
    public static final String UNIT = "unit";
    public static final String GROUP = "_group";
    public static final String IMEI = "imei";
    public static final String TIME = "time";
    public static final String PASSWORD = "password";

    public GeotableDBHelper(Context context) {
        super(context, GEOTABLE_DBNAME, null, 1);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL("CREATE table IF NOT EXISTS " +
                GEO_TABLE
                + " ("
                + "_id INTEGER PRIMARY KEY AUTOINCREMENT, "
                + GEO_ID + " integer,"
                + GEO_TITLE + " VARCHAR(128),"
                + POL_ID + " VARCHAR(128),"
                + PUSH_ID + " VARCHAR(128),"
                + PUSH_CHANNEL + " VARCHAR(128),"
                + NAME + " VARCHAR(128),"
                + UNIT + " VARCHAR(1024),"
                + GROUP + " VARCHAR(128),"
                + IMEI + " VARCHAR(128),"
                + TIME + " VARCHAR(128) "
                + " );"
        );
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        db.execSQL("ALTER TABLE " +
                        GEO_TABLE
                + " ADD COLUMN other TEXT");
    }
}
